using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class AccessDataSourceUpdatePage : System.Web.UI.Page
{
    GridView gridView;
    AccessDataSource acessDataSource;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        acessDataSource = new AccessDataSource();
        acessDataSource.DataFile =
        Server.MapPath(".") + "\\Northwind.mdb";
        
        
        gridView = new GridView();
        ShowCustomers("Canada", gridView);
        this.form1.Controls.Add(gridView);
        UpdateCustomers("BOTTM");
        gridView = new GridView();
        ShowCustomers("Canada", gridView);
        this.form1.Controls.Add(gridView);
    }
    void UpdateCustomers(string customerID)
    {
        acessDataSource.UpdateCommandType =
            SqlDataSourceCommandType.Text;
        acessDataSource.UpdateCommand =
        "Update Customers set "+
        " ContactName='Pham Huu Khang'" +       
        " where CustomerID=@CustomerID";
        acessDataSource.UpdateParameters.Add(
        "CustomerID", TypeCode.String, customerID);
        acessDataSource.Update();
    }
    void ShowCustomers(string countryName, GridView gridView)
    {
        acessDataSource.SelectCommandType =
            SqlDataSourceCommandType.Text;
        acessDataSource.SelectCommand =
        "select CustomerID,CompanyName, " +
        "ContactName,Address,City from Customers " +
        " where Country=@CountryName ";
        acessDataSource.SelectParameters.Add(
        "CountryName", TypeCode.String, countryName);
        gridView.DataSource = acessDataSource;
        gridView.DataBind();

    }
}
